home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / AmigaSystem / Scalos / GuiGFXLib / src / guigfx_bitmap.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  14.8 KB  |  731 lines

  1. /*********************************************************************
  2. ----------------------------------------------------------------------
  3.  
  4.     guigfx_bitmap
  5.  
  6. ----------------------------------------------------------------------
  7. *********************************************************************/
  8.  
  9. #include <render/render.h>
  10. #include <render/renderhooks.h>
  11. #include <datatypes/pictureclass.h>
  12. #include <datatypes/datatypes.h>
  13. #include <datatypes/datatypesclass.h>
  14. #include <datatypes/pictureclass.h>
  15. #include <datatypes/pictureclassext.h>
  16. #include <libraries/cybergraphics.h>
  17. #include <utility/tagitem.h>
  18. #include <graphics/gfx.h>
  19. #include <graphics/view.h>
  20. #include <exec/memory.h>
  21. #include <proto/dos.h>
  22.  
  23. #include <proto/render.h>
  24. #include <proto/graphics.h>
  25. #include <proto/exec.h>
  26. #include <proto/utility.h>
  27. #include <proto/datatypes.h>
  28. #include <proto/cybergraphics.h>
  29. #include <proto/dos.h>
  30.  
  31.  
  32. #include <guigfx/guigfx.h>
  33.  
  34. #include "guigfx_global.h"
  35. #include "guigfx_picturemethod.h"
  36. #include "guigfx_picture.h"
  37. #include "guigfx_bitmap.h"
  38.  
  39.  
  40. /*--------------------------------------------------------------------
  41.  
  42.     ReadBitMapArray    (bm, pic, displayID, tags)
  43.  
  44.     convert data from a bitmap structure to a prepared picture structure.
  45.     this function inserts the array and the pixelformat to the picture.
  46.  
  47.     GGFX_SourceX
  48.     GGFX_SourceY
  49.     GGFX_SourceWidth
  50.     GGFX_SourceHeight
  51.  
  52. --------------------------------------------------------------------*/
  53.  
  54. #ifndef __MORPHOS__
  55. BOOL ReadBitMapArray(struct BitMap *bm, PIC *pic, UWORD displayID, Tag tag1, ...)
  56. {
  57.     return ReadBitMapArrayA(bm, pic, displayID, (TAGLIST) &tag1);
  58. }
  59. #endif
  60.  
  61.  
  62. BOOL ReadBitMapArrayA(struct BitMap *bm, PIC *pic, UWORD displayID, TAGLIST tags)
  63. {
  64.     BOOL success = FALSE;
  65.     int width, height, pixelformat;
  66.     APTR array;
  67.  
  68.     if (array = ReadBitMap(bm, displayID, pic->palette, &pixelformat, &width, &height,
  69.         GGFX_SourceWidth, pic->width,
  70.         GGFX_DestWidth, pic->width,
  71.         TAG_DONE))
  72.     {
  73.         pic->owner = TRUE;    
  74.         pic->pixelformat = pixelformat;
  75.         pic->array = array;
  76.         success = TRUE;
  77.     }
  78.  
  79.     return success;
  80. }
  81.  
  82.  
  83.  
  84.  
  85. /*--------------------------------------------------------------------
  86.  
  87.  
  88.     num = GetBitMapInfo(bitmap, displayID, tags)
  89.     
  90.         BMAPATTR_Width
  91.  
  92.         BMAPATTR_Height
  93.  
  94.         BMAPATTR_Depth
  95.  
  96.         BMAPATTR_CyberGFX
  97.         
  98.         BMAPATTR_BitMapFormat    (returns actual bitmap format)
  99.     
  100.             PIXFMT_BITMAP_HAM8
  101.             PIXFMT_BITMAP_HAM6
  102.             PIXFMT_BITMAP_CLUT
  103.             PIXFMT_BITMAP_RGB
  104.  
  105.  
  106.         BMAPATTR_PixelFormat    (returns the applicable ggfx pixel format)
  107.         
  108.             PIXFMT_CHUNKY_CLUT
  109.             PIXFMT_0RGB_32
  110.         
  111.  
  112.         BMAPATTR_Flags
  113.             
  114.             returns BMF_ flags
  115.  
  116.  
  117. --------------------------------------------------------------------*/
  118.  
  119. #ifndef __MORPHOS__
  120. int GetBitMapInfo(struct BitMap *bm, UWORD displayID, Tag tag1, ...)
  121. {
  122.     return GetBitMapInfoA(bm, displayID, (TAGLIST) &tag1);
  123. }
  124. #endif
  125.  
  126.  
  127. int GetBitMapInfoA(struct BitMap *bm, UWORD displayID, TAGLIST tags)
  128. {
  129.     int count = 0;
  130.  
  131.     if (bm)
  132.     {
  133.  
  134.         BOOL cyberbitmap = FALSE;
  135.         LONG depth;
  136.         LONG *p;
  137.  
  138.         
  139.         depth = GetBitMapAttr(bm, BMA_DEPTH);
  140.     
  141.         if (CyberGfxBase)
  142.         {
  143.             if (GetCyberMapAttr(bm, CYBRMATTR_ISCYBERGFX))
  144.             {
  145.                 cyberbitmap = TRUE;
  146.                 depth = GetCyberMapAttr(bm, CYBRMATTR_DEPTH);
  147.             }
  148.         }
  149.  
  150.         if (p = (LONG *) GetTagData(BMAPATTR_Width, NULL, tags))
  151.         {
  152.             *p = GetBitMapAttr(bm, BMA_WIDTH);
  153.             count++;
  154.         }
  155.  
  156.         if (p = (LONG *) GetTagData(BMAPATTR_Height, NULL, tags))
  157.         {
  158.             *p = GetBitMapAttr(bm, BMA_HEIGHT);
  159.             count++;
  160.         }
  161.  
  162.         if (p = (LONG *) GetTagData(BMAPATTR_Depth, NULL, tags))
  163.         {
  164.             *p = depth;
  165.             count++;
  166.         }
  167.  
  168.         if (p = (LONG *) GetTagData(BMAPATTR_CyberGFX, NULL, tags))
  169.         {
  170.             *p = (LONG) cyberbitmap;
  171.             count++;
  172.         }
  173.  
  174.         if (p = (LONG *) GetTagData(BMAPATTR_BitMapFormat, NULL, tags))
  175.         {
  176.             if (cyberbitmap)
  177.             {
  178.                 if (depth > 8)
  179.                 {
  180.                     *p = PIXFMT_BITMAP_RGB;
  181.                 }
  182.                 else
  183.                 {
  184.                     *p = PIXFMT_BITMAP_CLUT;
  185.                 }
  186.             }
  187.             else
  188.             {
  189.                 if ((displayID != INVALID_ID) && (displayID & HAM))
  190.                 {
  191.                     switch (depth)
  192.                     {
  193.                         case 8:
  194.                             *p = PIXFMT_BITMAP_HAM8;
  195.                             break;
  196.                         case 6:
  197.                             *p = PIXFMT_BITMAP_HAM6;
  198.                             break;
  199.                         default:
  200.                             *p = PIXFMT_BITMAP_CLUT;
  201.                     }
  202.                 }
  203.                 else
  204.                 {
  205.                     *p = PIXFMT_BITMAP_CLUT;
  206.                 }
  207.             }
  208.             count++;
  209.         }
  210.  
  211.         if (p = (LONG *) GetTagData(BMAPATTR_PixelFormat, NULL, tags))
  212.         {
  213.             LONG bf;
  214.  
  215.             GetBitMapInfo(bm, displayID, BMAPATTR_BitMapFormat, &bf, TAG_DONE);
  216.         
  217.             switch (bf)
  218.             {
  219.                 case PIXFMT_BITMAP_HAM6:    
  220.                 case PIXFMT_BITMAP_HAM8:
  221.                 case PIXFMT_BITMAP_RGB:
  222.                     *p = PIXFMT_0RGB_32;
  223.                     break;
  224.                 
  225.                 default:
  226.                 case PIXFMT_BITMAP_CLUT:
  227.                     *p = PIXFMT_CHUNKY_CLUT;
  228.                     break;
  229.             }
  230.             count++;
  231.         }
  232.  
  233.         if (p = (LONG *) GetTagData(BMAPATTR_Flags, NULL, tags))
  234.         {
  235.             *p = GetBitMapAttr(bm, BMA_FLAGS);
  236.             count++;
  237.         }
  238.     
  239.     }
  240.  
  241.     return count;
  242. }
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249. /*---------------------------------------------------------------------
  250.  
  251.     readrgb
  252.  
  253.     callback for reading RGB data from a rastport
  254.  
  255. --------------------------------------------------------------------*/
  256.  
  257. struct readrgbdata
  258. {
  259.     int sourcewidth;
  260.     struct RastPort *rp;
  261.     int sourcex;
  262.     int sourcey;
  263.     int lastline;
  264. };
  265.  
  266.  
  267. #ifdef __MORPHOS__
  268. FUNC_HOOK(ULONG, readrgb, struct Hook *, hook, APTR, buffer, struct RND_LineMessage *, msg)
  269. #else
  270. ULONG ASM SAVE_DS readrgbfunc(    register __a0 struct Hook *hook,
  271.                                 register __a2 APTR buffer,
  272.                                 register __a1 struct RND_LineMessage *msg )
  273. #endif
  274. {
  275.     struct readrgbdata *data = hook->h_Data;
  276.  
  277.     if (msg->RND_LMsg_type == LMSGTYPE_LINE_FETCH)
  278.     {
  279.         if (data->lastline != msg->RND_LMsg_row)
  280.         {
  281.             data->lastline = msg->RND_LMsg_row;
  282.             ReadPixelArray(buffer, 0,0, data->sourcewidth * 4, data->rp,
  283.                 data->sourcex, data->sourcey + msg->RND_LMsg_row, data->sourcewidth, 1, RECTFMT_ARGB);
  284.         }
  285.     }
  286.  
  287.     return TRUE;
  288. }
  289.  
  290.  
  291.  
  292. /*---------------------------------------------------------------------
  293.  
  294.     readclut
  295.  
  296.     callback for reading chunky data from a rastport
  297.  
  298. --------------------------------------------------------------------*/
  299.  
  300. struct readclutdata
  301. {
  302.     int sourcewidth;
  303.     struct RastPort *rp, *temprp;
  304.     int sourcex;
  305.     int sourcey;
  306.     int lastline;
  307.  
  308. };
  309.  
  310.  
  311. #ifdef __MORPHOS__
  312. FUNC_HOOK(ULONG, readclut, struct Hook *, hook, APTR, buffer, struct RND_LineMessage *, msg)
  313. #else
  314. ULONG ASM SAVE_DS readclutfunc(    register __a0 struct Hook *hook,
  315.                                 register __a2 APTR buffer,
  316.                                 register __a1 struct RND_LineMessage *msg )
  317. #endif
  318. {
  319.     struct readclutdata *data = hook->h_Data;
  320.  
  321.     if (msg->RND_LMsg_type == LMSGTYPE_LINE_FETCH)
  322.     {
  323.         if (data->lastline != msg->RND_LMsg_row)
  324.         {
  325.             data->lastline = msg->RND_LMsg_row;
  326.             ReadPixelLine8(data->rp, data->sourcex, data->sourcey + msg->RND_LMsg_row, data->sourcewidth, buffer, data->temprp);
  327.         }
  328.     }
  329.  
  330.     return TRUE;
  331. }
  332.  
  333.  
  334.  
  335. /*---------------------------------------------------------------------
  336.  
  337.     readham
  338.  
  339.     callback for reading ham data from a rastport
  340.  
  341. --------------------------------------------------------------------*/
  342.  
  343. struct readhamdata
  344. {
  345.     int sourcewidth;
  346.     struct RastPort *rp, *temprp;
  347.     int sourcex;
  348.     int sourcey;
  349.     int lastline;
  350.     UBYTE *linebuffer;        // intermediate buffer for the HAM chunky bytes
  351.     PALETTE palette;
  352.     int colormode;
  353. };
  354.  
  355.  
  356. #ifdef __MORPHOS__
  357. FUNC_HOOK(ULONG, readham, struct Hook *, hook, APTR, buffer, struct RND_LineMessage *, msg)
  358. #else
  359. ULONG ASM SAVE_DS readhamfunc(    register __a0 struct Hook *hook,
  360.                                 register __a2 APTR buffer,
  361.                                 register __a1 struct RND_LineMessage *msg )
  362. #endif
  363. {
  364.     struct readhamdata *data = hook->h_Data;
  365.  
  366.     if (msg->RND_LMsg_type == LMSGTYPE_LINE_FETCH)
  367.     {
  368.         if (data->lastline != msg->RND_LMsg_row)
  369.         {
  370.             data->lastline = msg->RND_LMsg_row;
  371.             ReadPixelLine8(data->rp, 0, data->sourcey + msg->RND_LMsg_row, data->sourcewidth+data->sourcex, data->linebuffer, data->temprp);
  372.             Chunky2RGB(data->linebuffer, data->sourcewidth, 1, buffer, data->palette,
  373.                 RND_ColorMode, data->colormode,
  374.                 RND_LeftEdge, data->sourcex,
  375.                 TAG_DONE);
  376.         }
  377.     }
  378.  
  379.     return TRUE;
  380. }
  381.  
  382.  
  383.  
  384. /*--------------------------------------------------------------------
  385.  
  386.     array = ReadBitMap(bm, displayID, palette, *pixelformat, *width, *height, tags)
  387.     
  388.         read a bitmap to a pixel array.
  389.  
  390.         GGFX_SourceX
  391.         GGFX_SourceY
  392.         GGFX_SourceWidth
  393.         GGFX_SourceHeight
  394.         GGFX_DestWidth
  395.         GGFX_DestHeight
  396.  
  397. --------------------------------------------------------------------*/
  398.  
  399. #ifndef __MORPHOS__
  400. APTR ReadBitMap(struct BitMap *bm, UWORD displayID, PALETTE palette,
  401.     int *pixelformat, int *width, int *height,
  402.     Tag tag1, ...)
  403. {
  404.     return ReadBitMapA(bm, displayID, palette, 
  405.         pixelformat, width, height,
  406.         (TAGLIST) &tag1);
  407. }
  408. #endif
  409.  
  410. APTR ReadBitMapA(struct BitMap *bm, UWORD displayID, PALETTE palette,
  411.     int *ptr_pixelformat, int *ptr_width, int *ptr_height, TAGLIST tags)
  412. {
  413.     APTR array = NULL;
  414.  
  415.     if (bm)
  416.     {
  417.         BOOL success;
  418.         
  419.         int sourcex, sourcey, sourcewidth, sourceheight, destwidth, destheight;    
  420.         int width, height, flags, depth, iscyber, bmapformat, pixelformat;
  421.         int bufsize;
  422.         APTR scaleengine = NULL;
  423.         struct RastPort rp, temprp;
  424.     
  425.         sourcex = GetTagData(GGFX_SourceX, 0, tags);
  426.         sourcey = GetTagData(GGFX_SourceY, 0, tags);
  427.  
  428.         GetBitMapInfo(bm, displayID,
  429.             BMAPATTR_Width, &width,
  430.             BMAPATTR_Height, &height,
  431.             BMAPATTR_Depth, &depth,
  432.             BMAPATTR_Flags, &flags,
  433.             BMAPATTR_CyberGFX, &iscyber,
  434.             BMAPATTR_BitMapFormat, &bmapformat,
  435.             BMAPATTR_PixelFormat, &pixelformat,
  436.             TAG_DONE);
  437.  
  438.         sourcewidth = GetTagData(GGFX_SourceWidth, width, tags);
  439.         sourceheight = GetTagData(GGFX_SourceHeight, height, tags);
  440.         destwidth = GetTagData(GGFX_DestWidth, width, tags);
  441.         destheight = GetTagData(GGFX_DestHeight, height, tags);
  442.  
  443.  
  444.         success = TRUE;
  445.  
  446.  
  447.         //    insert bitmap into rastport, create temp rastport
  448.  
  449.         InitRastPort(&rp);
  450.         rp.BitMap = bm;
  451.         TurboCopyMem(&rp, &temprp, sizeof(struct RastPort));
  452.         temprp.Layer = NULL;
  453.         if (!(temprp.BitMap = AllocBitMap(width, 1, depth, flags, bm)))
  454.         {
  455.             success = FALSE;
  456.         }
  457.  
  458.  
  459.         //    create scale engine
  460.  
  461.         if (success)
  462.         {
  463.             if (sourcewidth != destwidth || sourceheight != destheight)
  464.             {
  465.                 if (!(scaleengine = CreateScaleEngine(
  466.                     sourcewidth, sourceheight,
  467.                     destwidth, destheight,
  468.                     RND_RMHandler, MemHandler,
  469.                     RND_PixelFormat, pixelformat,
  470.                     TAG_DONE)))
  471.                 {
  472.                     success = FALSE;
  473.                 }
  474.             }
  475.         }
  476.  
  477.  
  478.         //    get buffer
  479.  
  480.         if (success)
  481.         {
  482.             if (pixelformat == PIXFMT_0RGB_32)
  483.             {
  484.                 bufsize = destwidth * destheight * PIXELSIZE(pixelformat);
  485.             }
  486.             else
  487.             {
  488.                 bufsize = ((destwidth+15) & ~15) * destheight;
  489.             }
  490.  
  491.             DB(kprintf("!readbitmap alloc\n"));
  492.  
  493.             if (!(array = AllocRenderVec(MemHandler, bufsize)))
  494.             {
  495.                 success = FALSE;
  496.             }
  497.         }
  498.  
  499.  
  500.  
  501.         //    convert data
  502.         
  503.         if (success)
  504.         {
  505.             success = FALSE;
  506.  
  507.             if (scaleengine)
  508.             {
  509.  
  510.                 //    with scaling
  511.  
  512.                 switch (bmapformat)
  513.                 {
  514.                     case PIXFMT_BITMAP_RGB:
  515.                     {
  516.                         ULONG *linebuffer;
  517.  
  518.                         DB(kprintf("~reading/scaling RGB bitmap\n"));
  519.                         
  520.                         if (linebuffer = AllocRenderVec(MemHandler, sourcewidth * 4))
  521.                         {
  522.                             struct Hook readhook;
  523.                             struct readrgbdata hookdata;
  524.         
  525.                             hookdata.rp = &rp;
  526.                             hookdata.sourcex = sourcex;
  527.                             hookdata.sourcey = sourcey;
  528.                             hookdata.sourcewidth = sourcewidth;
  529.                             hookdata.lastline = -1;
  530.     
  531.                             readhook.h_Data = &hookdata;
  532. #ifdef __MORPHOS__
  533.                             readhook.h_Entry = (HOOKFUNC) &readrgb;
  534. #else
  535.                             readhook.h_Entry = (HOOKFUNC) readrgbfunc;
  536. #endif
  537.  
  538.                             Scale(scaleengine, linebuffer, array,
  539.                                 RND_SourceWidth, 0,
  540.                                 RND_LineHook, &readhook,
  541.                                 TAG_DONE);
  542.  
  543.                             FreeRenderVec(linebuffer);
  544.                             success = TRUE;
  545.                         }
  546.                         break;
  547.                     }
  548.                     case PIXFMT_BITMAP_CLUT:
  549.                     {
  550.                         UBYTE *linebuffer;
  551.  
  552.                         DB(kprintf("~reading/scaling CLUT bitmap\n"));
  553.  
  554.                         if (linebuffer = AllocRenderVec(MemHandler, ((sourcewidth+15) & ~15)))
  555.                         {
  556.                             struct Hook readhook;
  557.                             struct readclutdata hookdata;
  558.         
  559.                             hookdata.rp = &rp;
  560.                             hookdata.temprp = &temprp;
  561.                             hookdata.sourcex = sourcex;
  562.                             hookdata.sourcey = sourcey;
  563.                             hookdata.sourcewidth = sourcewidth;
  564.                             hookdata.lastline = -1;
  565.     
  566.                             readhook.h_Data = &hookdata;
  567. #ifdef __MORPHOS__
  568.                             readhook.h_Entry = (HOOKFUNC) &readclut;
  569. #else
  570.                             readhook.h_Entry = (HOOKFUNC) readclutfunc;
  571. #endif
  572.  
  573.                             Scale(scaleengine, linebuffer, array,
  574.                                 RND_SourceWidth, 0,
  575.                                 RND_LineHook, &readhook,
  576.                                 TAG_DONE);
  577.  
  578.                             FreeRenderVec(linebuffer);
  579.                             success = TRUE;
  580.                         }
  581.                         break;                    
  582.                     }
  583.  
  584.                     case PIXFMT_BITMAP_HAM6:
  585.                     case PIXFMT_BITMAP_HAM8:
  586.                     {
  587.                         UBYTE *linebuffer;
  588.                         ULONG *rgbbuffer;
  589.  
  590.                         DB(kprintf("~reading/scaling HAM bitmap\n"));
  591.  
  592.                         if (linebuffer = AllocRenderVec(MemHandler, ((sourcewidth + sourcex + 15) & ~15)))
  593.                         {
  594.                             if (rgbbuffer = AllocRenderVec(MemHandler, sourcewidth * 4))
  595.                             {
  596.                                 struct Hook readhook;
  597.                                 struct readhamdata hookdata;
  598.             
  599.                                 hookdata.rp = &rp;
  600.                                 hookdata.temprp = &temprp;
  601.                                 hookdata.sourcex = sourcex;
  602.                                 hookdata.sourcey = sourcey;
  603.                                 hookdata.sourcewidth = sourcewidth;
  604.                                 hookdata.linebuffer = linebuffer;
  605.                                 hookdata.palette = palette;
  606.                                 hookdata.colormode = (depth == 8) ? COLORMODE_HAM8 : COLORMODE_HAM6;
  607.                                 hookdata.lastline = -1;
  608.         
  609.                                 readhook.h_Data = &hookdata;
  610. #ifdef __MORPHOS__
  611.                                 readhook.h_Entry = (HOOKFUNC) &readham;
  612. #else
  613.                                 readhook.h_Entry = (HOOKFUNC) readhamfunc;
  614. #endif
  615.     
  616.                                 Scale(scaleengine, rgbbuffer, array,
  617.                                     RND_SourceWidth, 0,
  618.                                     RND_LineHook, &readhook,
  619.                                     TAG_DONE);
  620.     
  621.                                 FreeRenderVec(rgbbuffer);
  622.                                 success = TRUE;
  623.                             }
  624.                             FreeRenderVec(linebuffer);
  625.                         }
  626.                         break;                    
  627.                     }
  628.                 }
  629.             
  630.             }
  631.             else
  632.             {
  633.                 //    no scaling
  634.                 
  635.                 switch (bmapformat)
  636.                 {
  637.                     case PIXFMT_BITMAP_RGB:
  638.                     {
  639.                         DB(kprintf("~reading RGB bitmap\n"));
  640.                     
  641.                         ReadPixelArray(array, 0,0, destwidth * 4, &rp,
  642.                             sourcex, sourcey, destwidth, destheight, RECTFMT_ARGB);
  643.                         success = TRUE;
  644.                         break;
  645.                     }
  646.  
  647.                     case PIXFMT_BITMAP_CLUT:
  648.                     {
  649.                         int i;
  650.                         char *p = array;
  651.  
  652.                         DB(kprintf("~reading CLUT bitmap\n"));
  653.  
  654.                         for(i = 0; i < destheight; ++i)
  655.                         {
  656.                             ReadPixelLine8(&rp, sourcex, sourcey + i, destwidth, p, &temprp);
  657.                             p += destwidth;
  658.                         }
  659.                         success = TRUE;
  660.                         break;
  661.                     }
  662.                     
  663.                     case PIXFMT_BITMAP_HAM6:
  664.                     case PIXFMT_BITMAP_HAM8:
  665.                     {
  666.                         UBYTE *linebuffer;
  667.  
  668.                         DB(kprintf("~reading HAM bitmap\n"));
  669.  
  670.                         if (linebuffer = AllocRenderVec(MemHandler, ((destwidth+15) & ~15) ))
  671.                         {
  672.                             int i;
  673.                             ULONG *p = array;
  674.                             for(i = 0; i < destheight; ++i)
  675.                             {
  676.                                 ReadPixelLine8(&rp, sourcex, sourcey + i, destwidth, linebuffer, &temprp);
  677.  
  678.                                 Chunky2RGB(linebuffer, destwidth, 1, p, palette,
  679.                                     RND_ColorMode, ((depth == 8) ? COLORMODE_HAM8 : COLORMODE_HAM6),
  680.                                     TAG_DONE);
  681.  
  682.                                 p += destwidth;
  683.                             }
  684.                             FreeRenderVec(linebuffer);
  685.                             success = TRUE;
  686.                         }
  687.                         break;
  688.                     }
  689.  
  690.                 }
  691.             }
  692.         
  693.         }
  694.         
  695.         
  696.             
  697.  
  698.         //    close down
  699.  
  700.         if (success)
  701.         {
  702.             *ptr_pixelformat = pixelformat;
  703.             *ptr_width = destwidth;
  704.             *ptr_height = destheight;
  705.         }
  706.         else
  707.         {
  708.             if (array)
  709.             {
  710.                 FreeRenderVec(array);
  711.                 array = NULL;
  712.             }
  713.         }
  714.         
  715.         if (scaleengine)
  716.         {
  717.             DeleteScaleEngine(scaleengine);
  718.         }
  719.  
  720.         if (temprp.BitMap)
  721.         {
  722.             FreeBitMap(temprp.BitMap);
  723.         }
  724.  
  725.     }
  726.  
  727.     return array;
  728. }
  729.  
  730.  
  731.